#!/usr/bin/env python
# -*- coding: UTF-8 -*-

'''
Copyright (C) 2010 dbzhang800@gmail.com
All rights reserved.
''' 

import win32gui
import win32com
import win32com.client
import pythoncom
import time

class EventHandler:
    def OnVisible(self, visible):
        global bVisibleEventFired
        bVisibleEventFired = 1
    def OnDownloadBegin(self):
        print "DownloadBegin"
    def OnDownloadComplete(self):
        print "DownloadComplete"
    def OnDocumentComplete(self, pDisp = pythoncom.Missing , URL = pythoncom.Missing):
        print "documentComplete of %s" % URL

ie = win32com.client.DispatchWithEvents("InternetExplorer.Application", EventHandler)
ie.Visible = 1
ie.Navigate("www.xjtu.edu.cn")
pythoncom.PumpMessages()
ie.Quit()

